Using stdc++.h with clang on macOS

Metadata
aliases: []
shorthands: {}
created: 2022-06-26 21:33:18
modified: 2022-06-26 21:39:04

On macOS, the default C/C++ compiler is clang, located in /usr/bin/clang and /usr/bin/g++.

If we want to use the stdc++.h non-standard C++ header in our programs, then we have to add it to the /usr/local/include/bits/ folder.

  1. If it doesn't exist, create the bits folder
  2. Create a file named stdc++.h and paste the header file's contents, for example from here
  3. Test compatibility, if some of the headers induce errors, just simply comment them out from stdc++.h
#include <bits/stdc++.h>